import { fileURLToPath, URL } from 'url';

import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx';

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue(), vueJsx()],
  build: {
    // outDir: path.resolve(__dirname, '
  },
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),
    },
  },
  // css变量全局注册
  css: {
    preprocessorOptions: {
      scss: {
        additionalData:
          '@import "./src/styles/_variable.scss";@import "./src/styles/_mixins.scss";',
      },
    },
  },
  server: {
    proxy: {
      '/testApi': {
        // target: 'http://localhost:8080/',
        // target: 'http://114.116.24.108:8080/',
        target: 'http://127.0.0.1:8012/',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/testApi/, ''),
      },
    },
  },
});
